/**
 * 用户列表删除点击事件！
 */
function delUser() {
	var radio = $("input[type='radio']:checked").val()
	if(radio == null){
		mizhu.alert('操作提醒',"请选择一项进行操作");
		return false;
	}else{
		mizhu.confirm('温馨提醒', '要删除该用户吗？','确认', '取消', function(flag) {
			if (flag) {
				// ajax实现删除！
				$.post("AdminUserServlet", "action=del&id=" + radio, function(del) {
					// 删除成功与否弹出信息！
					var result = eval("(" + del + ")");
					if (result.status == 1) {
						mizhu.toast(result.message, 2000);
						var currentPage = $("#thisCurrentPage").val();
						var ise = {
							"mfatherid":2
						};
						$(".m_right").load( contextPath + "/AdminUserServlet?action=user .m_right>*", ise);
					}else{
						mizhu.alert('操作提醒',result.message);
					}
				});
			}
		})
	}
}

//分配权限
function userfpqx(){
	var radio = $("input[type='radio']:checked").val()
	if(radio == null){
		mizhu.alert('操作提醒',"请选择一项进行操作");
		return false;
	}else{
		var ise = {"id":radio};
		$(".m_right").load(contextPath + "/MenuServlet?action=index .m_right>*",ise);
	}
}

/**
 * 点击修改
 * @param id
 * @returns
 */
function updateByUserId() {
	var radio = $("input[type='radio']:checked").val()
	if(radio == null){
		mizhu.alert('操作提醒',"请选择一项进行操作");
		return false;
	}else{
		var ise = {"action":"toUpdateUser","id" : radio};
		$(".m_right").load(contextPath + "/AdminUserServlet .m_right>*",ise);
	}
}
/**
 * 点击添加
 * @returns
 */
function addUser() {
	var ise = {"action":"add"};
	$(".m_right").load(contextPath + "/AdminUserServlet .m_right>*",ise);
}

function hair(){
	var userid = $("#userid").val()
	var obj=document.getElementsByName('menuid'); //选择所有name="'test'"的对象，返回数组 
	var menuids =[];
	$('input[name="menuid"]:checked').each(function(){
		menuids.push($(this).val());
	}); 
	$.ajax({
		url:"MenuServlet?action=fpMenu",
		type:"post",
		data:{"menuids":menuids,"userid":userid},
		dataType:"json",
		traditional:true,
		success:function(data){
			if(data.status == 1){
				mizhu.alert('操作提醒',data.message);
			}else{
				mizhu.alert('操作提醒',"系统异常");
			}
		}
	})
}

//新增权限
function addMenu(){
	alert("addMenu")
}

//修改权限
function upMenu(){
	var radio = $("input[type='radio']:checked").val()
	if(radio == null){
		mizhu.alert('操作提醒',"请选择一项进行操作");
		return false;
	}else{
		alert(radio)
	}
}

//删除权限
function deleMenu(){
	var radio = $("input[type='radio']:checked").val()
	if(radio == null){
		mizhu.alert('操作提醒',"请选择一项进行操作");
		return false;
	}else{
		$.ajax({
			url:"MenuServlet?action=deleteMenu",
			type:"post",
			data:{
				"menuid":radio
			},
			success:function(data){
				if(radio > 0){
					mizhu.alert('操作提醒',"删除成功");
				}
			}
		})
	}
}

//全选
function setAll() {
	var loves = document.getElementsByName("menuid");
     for (var i = 0; i < loves.length; i++) {
         loves[i].checked = true;
	}
}

//反选
function setOthers() {
	var loves = document.getElementsByName("menuid");
	for (var i = 0; i < loves.length; i++) {
    	 if (loves[i].checked == false)
        	 loves[i].checked = true;
         else
        	loves[i].checked = false;
	}
}

//全不选函数
function setNo() {
	var loves = document.getElementsByName("menuid");
	for (var i = 0; i < loves.length; i++) {
		loves[i].checked = false;
	}
}








